//
//  BRMFaceLoginSwitchCell.m
//  BrezzeSaaS
//
//  Created by IOS on 2022/3/31.
//  Copyright © 2022 Brezze GWG. All rights reserved.
//

#import "BRMFaceLoginSwitchCell.h"
#import "BRMSwitchUIView.h"

@interface BRMFaceLoginSwitchCell ()
{
    BRMSwitchUIView *_switchBtn;
}

@end

@implementation BRMFaceLoginSwitchCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUI];
    }
    
    return self;
}

#pragma mark - Func --
- (void)setIsOn:(BOOL)isOn {
    _isOn = isOn;
    _switchBtn.isOn = isOn;
}
#pragma mark - UI --
- (void)setUI {
    
    UIView *contV = [[UIView alloc] init];
    [self.contentView addSubview:contV];
    [contV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.offset(0);
        make.bottom.offset(-4);
    }];
    contV.backgroundColor = kColorBGF5;
    
    __block CGFloat margin = 20;
    UILabel *faceL = [[UILabel alloc] init];
    faceL.font = [UIFont br_fontM:16];
    faceL.text = [GGFaceIdManManage gg_getSuportTypeStr];
    faceL.textColor = UIColorText1;
    [contV addSubview:faceL];
    [faceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(margin);
        make.centerY.offset(0);
    }];
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = kColorBGF5;
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.right.offset(0);
        make.height.mas_equalTo(4);
        make.bottom.offset(0);
    }];
    
    BRMSwitchUIView *switchBtn = [[BRMSwitchUIView alloc] init];
    switchBtn.userInteractionEnabled = YES;
    [contV addSubview:switchBtn];
    [switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.right.offset(-10);
        make.width.mas_equalTo(44);
        make.height.mas_equalTo(24);
    }];
    
    _switchBtn = switchBtn;
    WS(weakSelf);
    switchBtn.switchClickBlock = ^(BOOL isOn) {
        if (weakSelf.switchBlock) {
            
            weakSelf.switchBlock(isOn);
            
        }
    };
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
   
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
